# $Id: PKGBUILD 89965 2013-05-06 10:41:42Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=phpldapadmin
pkgver=1.2.3
pkgrel=2
pkgdesc="A PHP and hence web-based tool to administrate LDAP over the WWW"
arch=('any')
url="http://phpldapadmin.sourceforge.net/"
license=('GPL')
depends=('libldap' 'php' 'php-ldap')
makedepends=('optipng')
backup=("etc/webapps/phpldapadmin/.htaccess"
	"etc/webapps/phpldapadmin/config.php")
source=(http://downloads.sourceforge.net/project/phpldapadmin/phpldapadmin-php5/$pkgver/phpldapadmin-$pkgver.tgz)
md5sums=('59a49054039ceb852c2da377d8742360')

build() {
  cd $srcdir/phpldapadmin-${pkgver}/
  find -name '*.png' -exec optipng -quiet -force -fix {} \;
}

package() {
  _instdir=$pkgdir/usr/share/webapps/phpldapadmin
  mkdir -p ${_instdir} $pkgdir/etc/webapps/phpldapadmin
  cd ${_instdir}

  cp -ra $srcdir/phpldapadmin-${pkgver}/* .
  echo "deny from all" >$pkgdir/etc/webapps/phpldapadmin/.htaccess

  ln -s /etc/webapps/phpldapadmin/.htaccess ${_instdir}/.htaccess
  ln -s /etc/webapps/phpldapadmin/config.php ${_instdir}/config/config.php
  cp ${_instdir}/config/config.php.example $pkgdir/etc/webapps/phpldapadmin/config.php

  cat >$pkgdir/etc/webapps/phpldapadmin/apache.example.conf <<EOF
	Alias /phpldapadmin "/usr/share/webapps/phpldapAdmin"
	<Directory "/usr/share/webapps/phpldapAdmin">
		AllowOverride All
		Options FollowSymlinks
		Order allow,deny
		Allow from all
		php_admin_value open_basedir "/srv/:/tmp/:/usr/share/webapps/:/etc/webapps:/usr/share/pear/"
	</Directory>
EOF
}
